import { Base64UrlSafe } from '@aecworks/base64-url-safe';

class Base64Util {
    static encode(plainString) {
        return Base64UrlSafe.encode(plainString, false);
    }

    static decode(encodedString) {
        return Base64UrlSafe.decode(encodedString, false);
    }

    static encodeSafe(plainString) {
        return Base64UrlSafe.encode(plainString, true);
    }

    static decodeSafe(plainString) {
        return Base64UrlSafe.decode(plainString, true);
    }

    static decodeUrn(plainString) {
        const urn = plainString.replace(/-/g, '+').replace(/_/g, '/');
        return Base64UrlSafe.decode(urn);
    }
}

export { Base64Util };
